package com.gurid.service.base.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "讲师ID")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    //@JsonFiels(name = "id") //出参转换
    //@JsonProperty("id") //入参转换，否则前端传入的json包无法接收
    private String id;

    @Schema(description = "创建时间", example = "2019-01-01 8:00:00")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") //后端传入前端的日期格式化
    @TableField(fill = FieldFill.INSERT) // 这里只是通过MyBatis-Plus指定了什么时候填充，但是没有告诉程序如何填充
    private Date gmtCreate;

    @Schema(description = "更新时间", example = "2019-01-01 8:00:00")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") //后端传入前端的日期格式化
    @TableField(fill = FieldFill.INSERT_UPDATE) // 这里只是通过MyBatis-Plus指定了什么时候填充，但是没有告诉程序如何填充
    private Date gmtModified;
}
